//
//  CardlistTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/12.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "CardlistTableViewCell.h"

@interface CardlistTableViewCell ()
@property (nonatomic,strong) GLGWLabel * leftTitLabel;
@end

@implementation CardlistTableViewCell{
    GLGWLabel * unitLabel;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.leftTitLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self.contentView];
        self.leftTitLabel.text = @"品名";
//        self.leftTitLabel.backgroundColor = kRandomColor;
        //
        self.changeTextField = [[GLGWTextField alloc] initTitlePlaceholder:@"请选择" theFont:SYSTEMFONT(14) theTitColor:kColor_Rule_Black inSuperView:self.contentView];
        self.changeTextField.textAlignment = NSTextAlignmentRight;
        self.changeTextField.userInteractionEnabled = NO;
//        self.changeTextField.backgroundColor = kRandomColor;
        //
        unitLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self.contentView];
        unitLabel.textAlignment = NSTextAlignmentRight;
        [unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(12));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
    }
    return self;
}

-(void)setC_type:(CellType)c_type{
    _c_type = c_type;
}

-(void)setNameLeftStr:(NSString *)nameLeftStr{
    _nameLeftStr = nameLeftStr;
    self.leftTitLabel.text = _nameLeftStr;
    CGFloat leftWidth = [GLGWLabel sizeWithTheText:_nameLeftStr theLabelHeight:kHeightProportion_In_iPhoneTriploid(20) theTextFont:SYSTEMFONT(14)].width+kWidthProportion_In_iPhoneTriploid(5);
    [self.leftTitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
        make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(12));
        make.width.equalTo(@(leftWidth));
        make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
    }];
    //
    switch (_c_type) {
        case CellType_Entrust:
        case CellType_Picture:{
            [self.changeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.leftTitLabel.mas_right).offset(2);
                make.top.bottom.equalTo(self).offset(0);
                make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(45));
            }];
        }
            break;
        case CellType_CardList:{
            [self.changeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.leftTitLabel.mas_right).offset(2);
                make.top.bottom.equalTo(self).offset(0);
                make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(60));
            }];
        }
            break;
            
        default:
            break;
    }
}

-(void)setUnitStr:(NSString *)unitStr{
    _unitStr = unitStr;
    unitLabel.text = _unitStr;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
